app.service('revenueSettingService',['$q','utilService',function($q,utilService){

    //新增流水信息
    this.addRevenueSetting = function($scope){
        var deferred = $q.defer();
        utilService.api({
            url:$scope.app.domain + 'revenue/setting',
            data:$scope.revenueSetting,
            method:'POST'
        }).then(function(result){
            deferred.resolve(result);
        });
        return deferred.promise;
    }

    //查询ById
    this.findById = function($scope){
        var deferred = $q.defer();
        utilService.get({
            url:$scope.app.domain + 'revenue/setting/'+ $scope.revenueSetting.id,
            params:{id:$scope.revenueSetting.id}
        }).then(function(response){
            deferred.resolve(response.data);
        },function(e){
            console.error(e);
            deferred.reject("连接服务器出错");
        });
        return deferred.promise;
    }

    this.editRevenueSetting = function($scope){
        var deferred = $q.defer();
        utilService.api({
            url:$scope.app.domain + 'revenue/setting',
            data:$scope.revenueSetting,
            method:'PUT'
        }).then(function(result){
            deferred.resolve(result);
        });
        return deferred.promise;
    }


    this.delRevenueSetting = function($scope){
        var deferred = $q.defer();
        utilService.api({
            url:$scope.app.domain + 'revenue/setting/del',
            data:{id:$scope.revenueSetting.id},
            method:"PUT"
        }).then(function(result){
            deferred.resolve(result);
        });
        return deferred.promise;
    }
}])